package com.cskaoyan.shopping.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.mall.constant.ShoppingRetCode;
import com.cskaoyan.shopping.dto.PanelDto;
import com.cskaoyan.shopping.dto.ShoppingHomePageResponse;
import com.cskaoyan.shopping.dto.TestProductDetailDto;
import com.cskaoyan.shopping.dto.TestProductDetailResponse;
import com.cskaoyan.shopping.service.ITestProductService;
import com.cskaoyan.shopping.service.ShoppingHomePageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @auther zhangfuqiang
 * @date 2022/5/18:21:44
 */
@RestController
public class ShoppingHomePageController {

    @Autowired
    ShoppingHomePageService shoppingHomePageService;

    //http://localhost:8102/shopping/homepage
    @GetMapping("/shopping/homepage")
    public ResponseData getShoppingHomePage() {

        // 根据业务逻辑处理请求
        ShoppingHomePageResponse response = shoppingHomePageService.getShoppingHomePage();

        if (ShoppingRetCode.SUCCESS.getCode().equals(response.getCode())) {
            // 业务方法调用成功
            List<PanelDto> response2 = response.getResponse();
            return new ResponseUtil().setData(response2);
        }

        // 业务方法执行失败
        return new ResponseUtil().setErrorMsg(response.getMsg());

    }
}
